﻿namespace MyTRCP.Common.Models
{
    public class ResponsePayload
    {
        public ushort PayloadType { get; set; }
        public CmdIdEnum OriginalCmdId { get; set; }
        public RespErrorCodeEnum ErrorCodeEnum { get; set; }
        public byte[] Datas { get; set; }
        public ResponsePayload(DataPayload source)
        {
            if (source.Arguments.Length == 0)
                throw new Exception("载荷参数长度不足");
            PayloadType = source.PayloadType;
            OriginalCmdId = (CmdIdEnum)(source.CommandId & 0x7fff);
            ErrorCodeEnum = (RespErrorCodeEnum)source.Arguments[0];
            Datas = new byte[source.Arguments.Length - 1];
            if (source.Arguments.Length > 1)
                Array.Copy(source.Arguments, 1, Datas, 0, Datas.Length);
        }
    }
}